<?php
namespace Home\Controller;
use Think\Controller;

class CommonController extends Controller {
	
	//__construct
    public function _initialize(){
    	//visit_log();
    	$this->load_config();
    	$this->load_meta();

        //上传模块的用户登录检查
        if (CONTROLLER_NAME == "Update" or CONTROLLER_NAME== "User") {
        	# code...
        	define('UID',session('xuehao'));
			set_redirect_url(U('Update/index'));

	        if( !UID ){// 还没登录 跳转到登录页面
	            //$this->redirect('Public/login');
	            $this->error('请登陆！',U('Home/Public/login'));
	        }
        }
    }

	public function load_meta(){
		$this->assign('meta_title',C("WEB_SITE_TITLE"));
		$this->assign('meta_description',C("WEB_SITE_DESCRIPTION"));
		$this->assign('meta_keywords',C("WEB_SITE_KEYWORD"));
	}

	public function load_config($tr = true){

		/* 读取数据库中的配置 */
        $config	=	S('DB_CONFIG_DATA');
        if(!$config or $tr){
            $config	=	D('Config')->lists();
            S('DB_CONFIG_DATA',$config);
        }
		//dump($config);
        C($config); //添加配置
	}
}